﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using RaytracerLib;
using RaytracerLib.Layers;
using RaytracerLib.MathLib;
using RaytracerLib.RenderableObjects;
using RaytracerLib.Postprocessing.LightCorrector;
using RaytracerLib.Resamplers;
using RaytracerLib.Samplers;
using RaytracerLib.Volumes;
using TomanuExtensions;
using RaytracerLib.ShadowTesters;
using RaytracerLib.Attenuations;
using System.Reflection;
using RaytracerLib.Layers.Interpolators;
using RaytracerLib.Layers.OverlayCorrectors;
using RaytracerLib.Lights;
using System.Globalization;
using RaytracerLib.MathLib.Polynomials;
using RaytracerLib.UVMappers;
using RaytracerLib.MathLib.RootFinders;
using YAXLib;
using RaytracerLib.Cameras;
using RaytracerLib.Postprocessing;
using RaytracerLib.Resamplers.Filters;

namespace Raytracer.Generator
{
    public static partial class TestScenes
    {
        public static List<TestScene> List = new List<TestScene>();

        private static void Fast(Scene a_scene)
        {
            if (a_scene.ActiveCamera.Film.Resampler is FilterResampler)
                (a_scene.ActiveCamera.Film.Resampler as FilterResampler).Filter = new BoxFilter();
            a_scene.ActiveCamera.Film.Sampler = Sampler.Create(SamplerType.Grid);
            (a_scene.ActiveCamera.Film.Sampler as UniformSampler).Subresolution = 1;
        }

        static TestScenes()
        {
            var methods1 = typeof(TestScenes).GetMethods(BindingFlags.Static |
                BindingFlags.Public | BindingFlags.NonPublic);

            var methods2 = from m in methods1
                           where m.Name.StartsWith("Generate_")
                           orderby m.Name
                           select m;

            foreach (var method in methods2)
                method.Invoke(null, null);

            var indexes = from ts in List select ts.Index;
            var doubles = indexes.ExceptExact(indexes.Distinct()).ToArray();

            List = (from el in List
                    orderby el.Index
                    select el).ToList();

            if (doubles.Length > 0)
                throw new InvalidOperationException("Test scenes indexes are not unique");
        }
    }
}